﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:BillsManager.Views.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Values.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type Controls:ListBoxEx}">

        <Setter Property="Background" Value="{StaticResource View.Background}" />
        <Setter Property="BorderBrush" Value="{StaticResource Control.BorderBrush.Normal}" />
        <Setter Property="Foreground" Value="{StaticResource View.Foreground.Normal}" />

        <Setter Property="BorderThickness" Value="0" />

        <Setter Property="Padding" Value="0" />

        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:ListBoxEx}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{StaticResource Control.Border.CornerRadius}"
                            Padding="{TemplateBinding Padding}">
                        <ScrollViewer Focusable="false">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>

            <MultiDataTrigger>

                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0" />
                    <Condition Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=ShowEmptyMessage}" Value="true" />
                </MultiDataTrigger.Conditions>

                <MultiDataTrigger.Setters>

                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <TextBlock Margin="8"
                                           HorizontalAlignment="Center"
                                           Text="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent},
                                                          Path=EmptyMessage}" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>

                </MultiDataTrigger.Setters>

            </MultiDataTrigger>

            <Trigger Property="IsGrouping" Value="true">
                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
            </Trigger>

        </Style.Triggers>

    </Style>

</ResourceDictionary>